package org.code.boot.controller.boot;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.code.boot.common.annotation.Log;
import org.code.boot.common.enums.BusinessType;
import org.code.boot.controller.BaseController;
import org.code.boot.vo.AjaxResult;
import org.code.boot.domain.boot.BizTrainMeal;
import org.code.boot.service.boot.IBizTrainMealService;
import org.code.boot.vo.TableDataInfo;

/**
 * 火车餐信息Controller
 * 
 * @author coder
 * @date 2025-08-28
 */
@RestController
@RequestMapping("/boot/meal")
public class BizTrainMealController extends BaseController
{
    @Autowired
    private IBizTrainMealService bizTrainMealService;

    /**
     * 查询火车餐信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BizTrainMeal bizTrainMeal)
    {
        startPage();
        List<BizTrainMeal> list = bizTrainMealService.selectBizTrainMealList(bizTrainMeal);
        return getDataTable(list);
    }



    /**
     * 获取火车餐信息下拉选项列表
     */
    @GetMapping("/options")
    public AjaxResult getOptions()
    {
        List<BizTrainMeal> list = bizTrainMealService.selectBizTrainMealList(new BizTrainMeal());
        return success(list);
    }

    /**
     * 获取火车餐信息详细信息
     */
    @GetMapping(value = "/{mealId}")
    public AjaxResult getInfo(@PathVariable("mealId") Long mealId)
    {
        return success(bizTrainMealService.selectBizTrainMealByMealId(mealId));
    }

    /**
     * 新增火车餐信息
     */
    @Log(title = "火车餐信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTrainMeal bizTrainMeal)
    {
        bizTrainMeal.setCreateBy(getNickname());
        return toAjax(bizTrainMealService.insertBizTrainMeal(bizTrainMeal));
    }

    /**
     * 修改火车餐信息
     */
    @Log(title = "火车餐信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTrainMeal bizTrainMeal)
    {
        bizTrainMeal.setUpdateBy(getNickname());
        return toAjax(bizTrainMealService.updateBizTrainMeal(bizTrainMeal));
    }

    /**
     * 删除火车餐信息
     */
    @Log(title = "火车餐信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mealIds}")
    public AjaxResult remove(@PathVariable Long[] mealIds)
    {
        return toAjax(bizTrainMealService.deleteBizTrainMealByMealIds(mealIds));
    }
}
